﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


using System.ComponentModel;
using System.ComponentModel.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;


using System.Drawing;
using System.Drawing.Design;

using DotSpatial.Controls;

using DotSpatial.Data;
using DotSpatial.Symbology.Forms;
using DotSpatial.Symbology;

namespace HaGisPack
{
    public class PolygonSymbolEditor : UITypeEditor
    {

        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {

            IWindowsFormsEditorService DlgProvider;
            DlgProvider = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (DlgProvider != null)
            {
                DetailedPolygonSymbolDialog MyPlgSymDlg = new DetailedPolygonSymbolDialog((PolygonSymbolizer)value);
                if (DlgProvider.ShowDialog(MyPlgSymDlg) == DialogResult.OK)
                {
                    return MyPlgSymDlg.Symbolizer;
                }
                else
                    return value;

            }
            else
                return value;

            //return base.EditValue(context, provider, value);
        }

        public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        {
            return UITypeEditorEditStyle.Modal;
            //return base.GetEditStyle(context);
        }

    }
}
